<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.

-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.storage.mechanism.IEUserData</title>
<script src="../../base.js"></script>
<script>
  goog.require('goog.storage.mechanism.iterablemechanism_test');
  goog.require('goog.storage.mechanism.prefixedmechanism_test');
  goog.require('goog.storage.mechanism.mechanism_test');
  goog.require('goog.storage.mechanism.IEUserData');
  goog.require('goog.testing.jsunit');
  goog.require('goog.userAgent');
</script>
</head>
<body>
<script>

function testAvailability() {
  var mechanism = new goog.storage.mechanism.IEUserData('foo');
  if (goog.userAgent.IE && !goog.userAgent.isVersion(9)) {
    assertTrue(mechanism.isAvailable());
  }
}

function testBasicOperations() {
  var mechanism = new goog.storage.mechanism.IEUserData('foo');
  if (mechanism.isAvailable()) {
    goog.storage.mechanism.mechanism_test.runBasicTests(mechanism);
  }
}

function testIterableOperations() {
  var mechanism = new goog.storage.mechanism.IEUserData('foo');
  if (mechanism.isAvailable()) {
    goog.storage.mechanism.iterablemechanism_test.runIterableTests(mechanism);
  }
}

function testSharing() {
  var mechanismA = new goog.storage.mechanism.IEUserData('foo');
  if (mechanismA.isAvailable()) {
    var mechanismB = new goog.storage.mechanism.IEUserData('foo');
    assertTrue(mechanismB.isAvailable());
    goog.storage.mechanism.prefixedmechanism_test.runSharingTests(
        mechanismA, mechanismB);
  }
}

function testSeparation() {
  var mechanismA = new goog.storage.mechanism.IEUserData('fooA');
  if (mechanismA.isAvailable()) {
    var mechanismB = new goog.storage.mechanism.IEUserData('fooB');
    assertTrue(mechanismB.isAvailable());
    goog.storage.mechanism.prefixedmechanism_test.runSeparationTests(
        mechanismA, mechanismB);
  }
}

function testQuota() {
  var mechanism = new goog.storage.mechanism.IEUserData('foo');
  if (mechanism.isAvailable()) {
    // We should get at least 64 KiB.
    goog.storage.mechanism.mechanism_test.runQuotaTests(mechanism, 64 * 1024);
  }
}

// This is disabled because it is only suitable for manual testing
function flaky_testPersistence() {
  var mechanism = new goog.storage.mechanism.IEUserData('persistence_test');
  goog.storage.mechanism.mechanism_test.runPersistenceTests(mechanism);
}

</script>
</body>
</html>
